
#pragma once
#include "..\ctrls\imageservices.h"
#include "coolsbcustomdraw.h"

template <class T>
class ATL_NO_VTABLE CCoolSBListBox
{
public:
	void InitCoolSB()
	{
		T* pThis = static_cast<T*>(this);

		m_imgSBBar.LoadFromFile(__SF(_T("scrollbar_bar.bmp")));
		m_imgSBButton.LoadFromFile(__SF(_T("scrollbar_button.bmp")));
		m_imgSBThumb.LoadFromFile(__SF(_T("scrollbar_thumb.bmp")));

		m_CoolSBCustomDraw.InitDC(m_imgSBBar, m_imgSBThumb, m_imgSBButton);

		InitializeCoolSB(pThis->m_hWnd);
		CoolSB_SetSize(pThis->m_hWnd, SB_VERT, m_imgSBBar.GetWidth(), m_imgSBBar.GetWidth());
	}

public:
	BEGIN_MSG_MAP(T)
		REFLECTED_NOTIFY_CODE_HANDLER(NM_COOLSB_CUSTOMDRAW, OnCustomDraw)
	END_MSG_MAP()

// Handler prototypes (uncomment arguments if needed):
//	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
//	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
//	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

	LRESULT OnCustomDraw(int idCtrl, LPNMHDR pnmh, BOOL& /*bHandled*/)
	{
		return m_CoolSBCustomDraw.HandleCustomDraw(idCtrl, (NMCSBCUSTOMDRAW *)pnmh);
	}

protected:
	CMyImage m_imgSBBar;
	CMyImage m_imgSBButton;
	CMyImage m_imgSBThumb;
	CCoolSBCustomDraw m_CoolSBCustomDraw;
};
